<?php
/* SVN FILE: $Id: index.php 135 2009-08-19 06:32:42Z miha@nahtigal.com $ */
/**
 * Short description for index.php
 *
 * Long description for index.php
 *
 * PHP versions 4 and 5
 *
 * Copyright (c) 2009, Miha Nahtigal
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @filesource
 * @copyright     Copyright (c) 2009, Miha Nahtigal
 * @link          http://www.nahtigal.com/
 * @package       lil_blogs_app
 * @subpackage    lil_blogs_app.webroot
 * @since         v 1.0
 * @version       $Revision: 135 $
 * @modifiedby    $LastChangedBy: miha@nahtigal.com $
 * @lastmodified  $Date: 2009-08-19 06:32:42 +0000 (Wed, 19 Aug 2009) $
 * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
 */
	error_reporting(E_ALL);
	ini_set('display_errors', 0);
/**
 * Do not change
 */
	if (!defined('DS')) {
		define('DS', DIRECTORY_SEPARATOR);
	}
/**
 * Include local path configuration file which must not be commited to repository
 */
	if (file_exists(dirname(__FILE__).DS.'paths.php')) include dirname(__FILE__).DS.'paths.php';
/**
 * These defines should only be edited if you have cake installed in
 * a directory layout other than the way it is distributed.
 * When using custom settings be sure to use the DS and do not add a trailing DS.
 */

/**
 * The full path to the directory which holds "app", WITHOUT a trailing DS.
 *
 */
	if (!defined('ROOT')) {
		define('ROOT', dirname(dirname(dirname(__FILE__))));
	}
/**
 * The actual directory name for the "app".
 *
 */
	if (!defined('APP_DIR')) {
		define('APP_DIR', basename(dirname(dirname(__FILE__))));
	}
/**
 * The absolute path to the "cake" directory, WITHOUT a trailing DS.
 *
 */
	if (!defined('CAKE_CORE_INCLUDE_PATH')) {
		define('CAKE_CORE_INCLUDE_PATH', ROOT);
	}

/**
 * Editing below this line should not be necessary.
 * Change at your own risk.
 *
 */
	if (!defined('WEBROOT_DIR')) {
		define('WEBROOT_DIR', basename(dirname(__FILE__)));
	}
	if (!defined('WWW_ROOT')) {
		define('WWW_ROOT', dirname(__FILE__) . DS);
	}
	if (!defined('CORE_PATH')) {
		if (function_exists('ini_set') && ini_set('include_path', CAKE_CORE_INCLUDE_PATH . PATH_SEPARATOR . ROOT . DS . APP_DIR . DS . PATH_SEPARATOR . ini_get('include_path'))) {
			define('APP_PATH', null);
			define('CORE_PATH', null);
		} else {
			define('APP_PATH', ROOT . DS . APP_DIR . DS);
			define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
		}
	}
	if (!include(CORE_PATH . 'cake' . DS . 'bootstrap.php')) {
		echo "CakePHP core could not be found. This probably means that your are not using default directory structure. You should create a new file paths.php in your APP/webroot directory and set ROOT, APP_DIR and CAKE_CORE_INCLUDE PATH.";
		trigger_error("CakePHP core could not be found.", E_USER_ERROR);
	}
	if (!include(APP_PATH . 'config' . DS . 'database.php')) {
		echo "Database configuration could not be found. Please create a new file database.php in your APP/config directory. There is a database.php.default file in the same directory which you can use as a template for your DB configuration.";
		trigger_error("No database configuration in APP/config.", E_USER_ERROR);
	}
	
	uses('model' . DS . 'connection_manager');
	$db = ConnectionManager::getInstance();
	@$connected = $db->getDataSource('default');
	if (!$connected || !$connected->isConnected()) {
		die('LilBlogs are NOT able to connect to your database. Please check your database.php configuration in APP/config/database.php');
		trigger_error("Database connect error.", E_USER_ERROR);
	}

	if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') {
		return;
	} else {
		$Dispatcher = new Dispatcher();
		$Dispatcher->dispatch();
	}
	if (Configure::read() > 0) {
		echo "<!-- " . round(getMicrotime() - $TIME_START, 4) . "s -->";
	}
?>
